Omni-channel

Your customers don't stay on one channel. Anya tells DentalCo's agent in the app chat: "My dentist appointment is Friday at 3pm." A few minutes later she texts DentalCo's number "When is my appointment?", and the agent answers that it is Friday at 3pm.

Episode cards do this. The agent keeps a card for each conversation: its last lines while it goes on, then a summary once it ends. The cards go into Anya's omni-channel. Her next app chat, and her next text once her number is linked, start with the cards of her app chats.

Turn on episode cards

Turn on episode_cards for the agent. This example uses support-sms, the agent that answers texts on your number in SMS:

CONFIG_ID=$(getstream agents api ListAgentConfigs --request '{"name": "support-sms"}' --jq '.[0].id')
getstream agents api PatchAgentConfig --id "$CONFIG_ID" --request '{"episode_cards": true}'

episode_cards is off by default.

The app chat knows Anya by her Stream user id. SMS knows her by her phone number. Your backend tells the agent that they are one person. $SERVER_TOKEN is a server token:

curl -X PUT "$STREAM_ACCELERATION_URL/v1/agents/users/anya" \
  -H "api_key: $STREAM_API_KEY" -H "stream-auth-type: jwt" \
  -H "Authorization: Bearer $SERVER_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"phone": "+15551234567"}'
Info:

No SDK wraps this call. Send it from your backend with any HTTP client, as above.

We recommend linking the number when the person adds it to their profile in your app. Without the link, the agent remembers the app chat and the texts separately.

  • A number that another user holds is refused.
  • {"phone": null} unlinks the number.

Remember the app chat

Your backend opens Anya's chat with the agent as a Stream Chat channel of type agent. Anya is its only member, and the channel's data sets agent_config_id to the id of support-sms, the agent that answers her texts. Cards are kept per agent, so the app chat and the texts must use the same agent. A dispatch worker answers the messages.

To try it, write as Anya: "My dentist appointment is Friday at 3pm." Then text DentalCo's number from +15551234567: "When is my appointment?" The agent answers by SMS that it is Friday at 3pm, which only the app chat holds.

Cards are written and read only in a chat whose members are the person alone, or the person and the agent. A group chat gets no cards, so one person's conversations never reach the others in it.

When a conversation ends

A conversation ends after an hour with no new message. The agent then replaces the card's last lines with a summary of the conversation.

Going further