简体   繁体   English

Twilio可编程聊天; 停止客户端发送消息

[英]Twilio Programmable Chat; Stopping client to send message

Hi Twilio Evangelists, 嗨,Twilio宣传员,

We are using Twilio module Programmable chat and using Javascript Client and Twilio.API C# server APIs. 我们正在使用Twilio模块可编程聊天,并使用Javascript客户端和Twilio.API C#服务器API。

We want user to see the Channels and Messages for the particular channel but need to refrain them from sending messages, conditionally. 我们希望用户看到特定频道的频道和消息,但需要避免它们有条件地发送消息。

We can keep UI elements disabled, but smart user would still be able to to access the Twilio client, and send message. 我们可以禁用UI元素,但是聪明的用户仍然可以访问Twilio客户端并发送消息。

Twilio developer evangelist here. Twilio开发人员布道者在这里。

You've pointed out that you could use the webhooks to stop a message being sent, but that's not the solution you want. 您已经指出,可以使用webhooks停止发送消息,但这不是您想要的解决方案。 I would have suggested it though! 我会建议的!

Another way would be to use the Programmable Chat REST API to load the Channels and the Messages . 另一种方法是使用Programmable Chat REST API加载频道消息 That way you could display the messages, but the user would not be logged into the service on the client side. 这样,您可以显示消息,但是用户将不会登录到客户端上的服务。 Then, only when you are ready to allow them to send a message, you can initiate the JS Client 然后,只有在准备好允许他们发送消息时,您才能启动JS客户端

One other possibility would be to initiate the JS Client, load all the channels and messages and then discard the client and token. 另一种可能性是启动JS客户端,加载所有通道和消息,然后丢弃客户端和令牌。

Let me know if that helps at all. 让我知道是否有帮助。

It is possible. 有可能的。

Permission model docs: https://www.twilio.com/docs/api/chat/guides/permissions 权限模型文档: https : //www.twilio.com/docs/api/chat/guides/permissions

Create a role using REST: https://www.twilio.com/docs/api/chat/rest/roles (note sendMessage permission you need to skip). 使用REST创建角色: https : //www.twilio.com/docs/api/chat/rest/roles (请注意,您需要跳过sendMessage权限)。

Then you have two options -- either to disallow all channel users of service to post messages by default (update DefaultChannelRoleSid for service and add a pre-webhook to assign a role with separate REST request to assign wider role to specific users) or add a pre-webhook on onMemberAdded event blocking the join by default and then adding manually via rest user to channel and assigning member a required role. 然后,您有两个选择-禁止所有服务的通道用户默认发布消息(更新service的DefaultChannelRoleSid并添加pre-webhook以使用单独的REST请求分配角色,以将更广泛的角色分配给特定用户)或添加在onMemberAdded事件上进行pre-webhook默认情况下会阻止连接,然后通过其余用户手动将其添加到通道并为成员分配所需的角色。

You can't do this from inside the webhook processing at the moment, so you will have to trigger some external URL that will issue the REST request. 您目前无法从webhook处理内部执行此操作,因此您将必须触发一些外部URL,这些URL会发出REST请求。

To update the role of the member of a channel, issue POST request to the member URL providing new RoleSid parameter. 要更新通道成员的角色,请向提供新RoleSid参数的成员URL发出POST请求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM