airyhq / airy

💬 Open Source App Framework to build streaming apps with real-time data - 💎 Build real-time data pipelines and make real-time data universally accessible - 🤖 Join historical and real-time data in the stream to create smarter ML and AI applications. - ⚡ Standardize complex data ingestion and stream data to apps with pre-built connectors
https://airy.co/docs/core
Apache License 2.0
368 stars 44 forks source link

Enhance webhook messages with contact and contact events #2753

Open steffh opened 2 years ago

steffh commented 2 years ago

Is your feature request related to a problem? Please describe.

As an Airy user I want to enrich the context of messages by tracking and ingesting relevant events that happened in regards to a contact (e.g. "Item purchased") so that I can "join" these events in the stream with conversational data in a way that e.g. a message.created event can be processed by an NLP microservice already having this enriched context so that such NLP microservice doesn't have to send out another API call to query an external data store e.g. for recent purchases

Describe the solution you'd like

See this discussion thread for more context.

Introduce a new webhook event context-message.created which will be triggered in the same way as message.created but will include the required context.

{
  "type": "context-message.created",
  "payload": {
    "conversation_id": "{UUID}",
    "channel_id": "{UUID}",
    "message": {
      "id": "{UUID}",
      "content": {"text": "Hello World"}, // source message payload
      "delivery_state": "pending|failed|delivered", // delivery state of message, one of pending, failed, delivered
      "from_contact": true,
      "sent_at": "2020-10-25T21:24:54.560Z", // ISO 8601 date string
      "source": "facebook", // messaging source
      // details about the sender
      "sender": {
        "id": "github:12345" // For unauthenticated instances this defaults to "airy-core-anonymous"
      }
    },
    "contact": {
      "id": "6b80b10c-ae6e-4995-844d-c56c4da11623",
      "display_name": "Margaret Hamilton",
      // ... All other relevant contact information
      "conversations": { // This payload is the same as the one returned by the new contact conversation view
        "conversation-id": {
          "source": "salesforce_history",
          // metadata?
          "data": [], // Same as for paginated message list https://airy.co/docs/core/api/endpoints/messages#list
          "pagination_data": {}
        }
      }
    }
  }
}
M-Shorouk commented 1 year ago

@chrismatix @AitorAlgorta are we still working on this? Its "In Progress"

AitorAlgorta commented 1 year ago

Hey, I don't think so

AitorAlgorta commented 1 year ago

let's move it back