Thank you very much for ahize! Integrating my React SPA with Chatwoot was being a nightmare until I found this package.
The issue
I found what seems to be limitation of ahize's API:
setAttribute only allows setting one attribute per call and each call makes a set_custom_attributes POST request to Chatwoot, which seems to set the entire "attributes object" of the conversation on Chatwoot, instead of merging new attributes into the ones it already has (which makes sense since it's a POST not a PATCH).
await chatwoot.setAttribute({
scope: 'conversation',
key: 'tenant_id',
value: tenant.id,
});
await chatwoot.setAttribute({
scope: 'conversation',
key: 'tenant_name',
value: tenant.name,
});
// After this, only `tenant_name` will be set
Solution
I believe a good solution would be to deprecate setAttribute in favor of a setAttributes method that accepts an object instead of a single key-value pair.
Thank you very much for
ahize! Integrating my React SPA with Chatwoot was being a nightmare until I found this package.The issue
I found what seems to be limitation of
ahize's API:setAttributeonly allows setting one attribute per call and each call makes aset_custom_attributesPOSTrequest to Chatwoot, which seems to set the entire "attributes object" of the conversation on Chatwoot, instead of merging new attributes into the ones it already has (which makes sense since it's a POST not a PATCH).Solution
I believe a good solution would be to deprecate
setAttributein favor of asetAttributesmethod that accepts an object instead of a single key-value pair.