In Twilio Conversations, an identity is unique to a User and may be signed in on multiple devices simultaneously.
For example, the identity "email@example.com" for a given User will stay synchronized on a number of endpoints, including their iPhone, Android tablet and in-browser application. All destinations for the same User will receive identical Conversation and Message notifications, as well as display the same message history.
On the server, you must decide two things based on the token request that you received:
- who the User is
- what they should be allowed to do
To figure out who the user is (their identity), you might use your existing login system or identity provider. You can use session cookies, an API token, or whatever mechanism you use to secure API requests or pages today.
You might not care who a User is at all, and assign them a temporary identity. Who the User is, what is their role, and how you determine that will vary from application to application.
If you determine that the User should indeed be allowed to access your Conversations application, you must grant your User access to a Conversation and supply an identity. Here are the guidelines on how to generate JWT access tokens: Creating Access Tokens.
Twilio Conversations also uses identity to track monthly usage and generate accounting reports. Therefore, you should be mindful about provisioning a reasonable amount of unique identities. Reusing identities too frequently and keeping uniqueness low may cause conflicts in the User and application logic. On the other hand, using only random identities will result in a large number of redundant unique Users, which also impacts monthly billing.
Twilio Conversations tracks unique User identities each month, and each unique
identity connecting to a Conversation Service will create a User record. During a calendar month, if a User registers activity, they are considered "active." The following activities register Users as "active Users":
- User is created via the REST API
- User is updated via the REST API
- User authenticates via the SDK
- User sends a Message from the SDK
- User sends a Message from SDK
- A Message is sent on behalf of a User from the REST API
- User joins a Conversation via the SDK
- User is added to a Conversation via REST API or SDK
- User is removed from a Conversation via REST or SDK
To minimize costs related to active Users:
- avoid creating the Conversations client object (in the SDK) until you are certain that the User wants to read/send messages
- avoid unnecessary REST API updates to Users, such as changing User attributes
誰しもが一度は考える「コーディングって難しい」。そんな時は、お問い合わせフォームから質問してください。 または、Stack Overflow でTwilioタグのついた情報から欲しいものを探してみましょう。