dhisana 0.0.1.dev255__py3-none-any.whl → 0.0.1.dev257__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -246,129 +246,144 @@ async def generate_inbound_email_response_copy(
246
246
  sender_data = cleaned_context.sender_info or SenderInfo()
247
247
 
248
248
  prompt = f"""
249
- You are a specialized email assistant.
250
- Your task is to analyze the user's email thread, the user/company info,
251
- and the provided triage guidelines to craft an appropriate response.
252
-
253
- Follow these instructions to generate the reply:
254
- {variation}
255
-
256
- 1. Email thread or conversation to respond to:
257
- {[thread_item.model_dump() for thread_item in cleaned_context.current_conversation_context.current_email_thread]
258
- if cleaned_context.current_conversation_context.current_email_thread else []}
259
-
260
- 2) Lead Information:
261
- {lead_data.dict()}
262
-
263
- Sender Information:
264
- Full Name: {sender_data.sender_full_name or ''}
265
- First Name: {sender_data.sender_first_name or ''}
266
- Last Name: {sender_data.sender_last_name or ''}
267
- Bio: {sender_data.sender_bio or ''}
268
-
269
-
270
- 3. Campaign-specific triage guidelines (user overrides always win):
271
- {cleaned_context.campaign_context.email_triage_guidelines}
272
-
273
- -----------------------------------------------------------------
274
- Core decision logic
275
- -----------------------------------------------------------------
276
- • If the request is routine, non-sensitive, and clearly actionable
277
- → **triage_status = "AUTOMATIC"**.
278
- If the thread contains PII, finance, legal, or any sensitive/NSFW content
279
- → **triage_status = "END_CONVERSATION"** and give a concise **triage_reason**.
280
-
281
- 4. Choose exactly ONE of: {allowed_actions}
282
-
283
- -----------------------------------------------------------------
284
- Response best practices
285
- -----------------------------------------------------------------
286
- MAX 150 words, friendly & concise, single clear CTA.
287
- Begin with a thank-you, mirror the prospect’s wording briefly, then answer /
288
- propose next step.
289
- Never contradict, trash-talk, or disparage {campaign_context.lead_info.organization_name}.
290
- • Plain-text only – NO HTML tags (<a>, <b>, <i>, etc.).
291
- • If a link already exists in the inbound email, include it verbatim—do not re-wrap or shorten.
292
-
293
- Meeting & follow-up rules
294
- -------------------------
295
- 1. Let `meeting_offer_sent` = **true** if any earlier assistant message offered a
296
- meeting.
297
- 2. If First “Thanks / Sounds good” & *no* prior meeting offer
298
- **SEND_REPLY** asking for a 15-min call (≤150 words).
299
- 3. If Second non-committal reply *after* meeting_offer_sent, or explicit “not interested”
300
- **END_CONVERSATION**.
301
- 4. If prospect explicitly asks for times / requests your link
302
- **SCHEDULE_MEETING** and confirm or propose times.
303
- 5. If One unsolicited follow-up maximum; stop unless prospect re-engages.
304
-
305
- If you have not proposed a meeting even once in the thread, and the user response is polite acknowledgment then you MUST request for a meeting.
306
-
307
-
308
- Objections & info requests
309
- --------------------------
310
- Pricing / docs / case-studies request → **NEED_MORE_INFO**.
311
- • Budget, timing, or competitor concerns → **OBJECTION_RAISED**
312
- (acknowledge + one clarifying Q or concise value point).
313
- “Loop in {{colleague_name}}” **FORWARD_TO_OTHER_USER**.
314
-
315
- Unsubscribe & priority handling
316
- -------------------------------
317
- 1. “Unsubscribe / Remove me” → **UNSUBSCRIBE**
318
- 2. Clear lack of interest **NOT_INTERESTED**
319
- 3. Auto OOO reply **OOF_MESSAGE**
320
- 4. Explicit meeting request → **SCHEDULE_MEETING**
321
- 5. Otherwise follow the Meeting & follow-up rules above
322
- 6. Default **END_CONVERSATION**
323
-
324
- Style guard-rails
325
- -----------------
326
- • Plain language; no jargon or filler.
327
- Do **not** repeat previous messages verbatim.
328
- • Signature must include sender_first_name exactly as provided.
329
- • Check UNSUBSCRIBE / NOT_INTERESTED first before other triage.
330
-
331
- If you have not proposed a meeting even once in the thread, and the user response is polite acknowledgment then you MUST request for a meeting.
332
-
333
- Meeting ask template example:
334
- Hi {{lead_first_name}}, would you be open to a quick 15-min call to
335
- understand your use-case and share notes?
336
-
337
- • Competitor-stack mention template example:
338
- Hi {{lead_first_name}}, thanks for sharing your current stack. Would you be
339
- open to a 15-min call to explore where we can add value?
340
-
341
- Use conversational name for company name.
342
- Use conversational name when using lead first name.
343
- Do not use special characters or spaces when using lead’s first name.
344
- In the subject or body DO NOT include any HTML tags like <a>, <b>, <i>, etc.
345
- The body and subject should be in plain text.
346
- If there is a link provided in the email, use it as is; do not wrap it in any HTML tags.
347
- DO NOT make up information. Use only the information provided in the context and instructions.
348
- Do NOT repeat the same message sent to the user in the past.
349
- Keep the thread conversational and friendly as a good account executive would respond.
350
- Do NOT rehash/repeat the same previous message already sent. Keep the reply to the point.
351
- DO NOT try to spam users with multiple messages.
352
- Current date is: {current_date_iso}.
353
- DO NOT share any link to internal or made up document. You can attach or send any document.
354
- If the user is asking for any additional document END_CONVERSATION and let Account executive handle it.
355
- - Make sure the body text is well-formatted and that newline and carriage-return characters are correctly present and preserved in the message body.
356
- - Do Not use em dash in the generated output.
357
-
358
- Required JSON output
359
- --------------------
360
- {{
249
+ You are a B2B account executive replying to warm inbound or engaged leads.
250
+
251
+ Your goal is to sound natural, helpful, and human while following all triage,
252
+ compliance, and action rules below.
253
+
254
+ Write responses the way a strong AE would type them, not like a system message.
255
+
256
+ =====================================================
257
+ INPUT CONTEXT
258
+ =====================================================
259
+
260
+ 1) Email thread to respond to:
261
+ {[thread_item.model_dump() for thread_item in cleaned_context.current_conversation_context.current_email_thread]
262
+ if cleaned_context.current_conversation_context.current_email_thread else []}
263
+
264
+ 2) Lead information:
265
+ {lead_data.dict()}
266
+
267
+ Sender information:
268
+ - Full name: {sender_data.sender_full_name or ''}
269
+ - First name: {sender_data.sender_first_name or ''}
270
+ - Last name: {sender_data.sender_last_name or ''}
271
+ - Bio: {sender_data.sender_bio or ''}
272
+
273
+ 3) Campaign-specific triage guidelines
274
+ (User overrides always take priority):
275
+ {cleaned_context.campaign_context.email_triage_guidelines}
276
+
277
+ =====================================================
278
+ TRIAGE DECISION LOGIC
279
+ =====================================================
280
+
281
+ Decide first. Write second.
282
+
283
+ • Routine, non-sensitive, clearly actionable
284
+ triage_status = "AUTOMATIC"
285
+
286
+ PII, finance, legal, contracts, compliance, NSFW,
287
+ or document requests
288
+ triage_status = "END_CONVERSATION"
289
+ Include a brief triage_reason
290
+
291
+ =====================================================
292
+ ACTION SELECTION
293
+ =====================================================
294
+
295
+ Choose exactly ONE action from:
296
+ {allowed_actions}
297
+
298
+ Priority order:
299
+ 1. UNSUBSCRIBE
300
+ 2. NOT_INTERESTED
301
+ 3. OOF_MESSAGE
302
+ 4. SCHEDULE_MEETING
303
+ 5. FORWARD_TO_OTHER_USER
304
+ 6. NEED_MORE_INFO
305
+ 7. OBJECTION_RAISED
306
+ 8. SEND_REPLY
307
+ 9. END_CONVERSATION
308
+
309
+ =====================================================
310
+ HOW THE RESPONSE SHOULD SOUND
311
+ =====================================================
312
+
313
+ This is a warm lead. Assume positive intent.
314
+
315
+ Friendly, relaxed, and conversational
316
+ • Short sentences. Natural pacing.
317
+ One clear idea per paragraph
318
+ No sales pressure. No hype. No buzzwords.
319
+ Helpful first. Next step second.
320
+
321
+ Think:
322
+ "Thanks for reaching out. Happy to help."
323
+ Not:
324
+ "Thank you for your inquiry regarding..."
325
+
326
+ =====================================================
327
+ RESPONSE STRUCTURE (LOOSE, NOT FORMAL)
328
+ =====================================================
329
+
330
+ Typical flow:
331
+ 1. Quick thank-you or acknowledgement
332
+ 2. Briefly mirror what they said or asked
333
+ 3. Answer or clarify in plain language
334
+ 4. Suggest a simple next step, if appropriate
335
+
336
+ Do not force all steps if it feels unnatural.
337
+
338
+ =====================================================
339
+ HARD RULES
340
+ =====================================================
341
+
342
+ Plain text only. No HTML.
343
+ Do not repeat previous messages verbatim.
344
+ Do not invent information, pricing, links, or docs.
345
+ If a link exists in the inbound email, reuse it exactly.
346
+ Do not add new links or attachments.
347
+ If documents are requested, END_CONVERSATION.
348
+ Never contradict or disparage {campaign_context.lead_info.organization_name}.
349
+ Do not spam or over-message.
350
+
351
+ =====================================================
352
+ NAMING AND STYLE
353
+ =====================================================
354
+
355
+ Use conversational company name
356
+ Use conversational lead first name
357
+ • Do not use special characters or spaces when referencing lead first name
358
+ Signature must include sender_first_name exactly as provided
359
+ • Preserve clean spacing and newlines
360
+ • Do NOT use em dash
361
+ • Keep it human. Avoid templates.
362
+
363
+ =====================================================
364
+ OUTPUT FORMAT (STRICT JSON)
365
+ =====================================================
366
+
367
+ Return valid JSON only.
368
+
369
+ {
361
370
  "triage_status": "AUTOMATIC" or "END_CONVERSATION",
362
- "triage_reason": "<reason if END_CONVERSATION; otherwise null>",
371
+ "triage_reason": "<string if END_CONVERSATION, otherwise null>",
363
372
  "response_action_to_take": "one of {allowed_actions}",
364
- "response_message": "<the reply body if response_action_to_take is SEND_REPLY or SCHEDULE_MEETING; otherwise empty>"
365
- }}
373
+ "response_message": "<reply body only if SEND_REPLY or SCHEDULE_MEETING, otherwise empty>"
374
+ }
375
+
376
+ =====================================================
377
+ SYSTEM CONTEXT
378
+ =====================================================
366
379
 
367
- Current date is: {current_date_iso}.
368
- -----------------------------------------------------------------
380
+ Current date: {current_date_iso}
381
+ • Use only provided context
382
+ • If unsure, choose END_CONVERSATION
369
383
  """
370
384
 
371
385
 
386
+
372
387
  # If there's a vector store ID, use that approach
373
388
  if (
374
389
  cleaned_context.external_known_data
@@ -33,7 +33,7 @@ from dhisana.schemas.common import (SendEmailContext, QueryEmailContext, ReplyEm
33
33
  # HELPER FUNCTIONS
34
34
  ################################################################################
35
35
 
36
- def get_google_workspace_token(tool_config: Optional[List[Dict]] = None) -> str:
36
+ def get_google_workspace_token(tool_config: Optional[List[Dict]] = None) -> Any:
37
37
  """
38
38
  Retrieves the GOOGLE_SERVICE_KEY (base64-encoded JSON) from the provided tool configuration or environment.
39
39
 
@@ -43,7 +43,7 @@ def get_google_workspace_token(tool_config: Optional[List[Dict]] = None) -> str:
43
43
  where "configuration" is a list of dictionaries containing "name" and "value" keys.
44
44
 
45
45
  Returns:
46
- str: The base64-encoded JSON string for the service account credentials.
46
+ Any: The service account payload (JSON string, base64 string, or dict) for credentials.
47
47
 
48
48
  Raises:
49
49
  ValueError: If the Google Workspace integration has not been configured.
@@ -75,6 +75,29 @@ def get_google_workspace_token(tool_config: Optional[List[Dict]] = None) -> str:
75
75
  return GOOGLE_SERVICE_KEY
76
76
 
77
77
 
78
+ def _normalize_service_account_info(service_account_json: Any) -> Dict[str, Any]:
79
+ """
80
+ Normalize a service account payload into a dict for Credentials.from_service_account_info.
81
+ Accepts dict, JSON string, or base64-encoded JSON string.
82
+ """
83
+ if isinstance(service_account_json, dict):
84
+ return service_account_json
85
+ if isinstance(service_account_json, (bytes, bytearray)):
86
+ service_account_json = service_account_json.decode("utf-8")
87
+ if not isinstance(service_account_json, str):
88
+ raise TypeError(
89
+ "Google Workspace service account payload must be a dict, str, bytes, or bytearray."
90
+ )
91
+ try:
92
+ return json.loads(service_account_json)
93
+ except json.JSONDecodeError:
94
+ try:
95
+ decoded = base64.b64decode(service_account_json).decode("utf-8")
96
+ except (ValueError, UnicodeDecodeError) as exc:
97
+ raise ValueError("Invalid Google Workspace service account payload.") from exc
98
+ return json.loads(decoded)
99
+
100
+
78
101
 
79
102
  def get_google_credentials(
80
103
  sender_email: str,
@@ -97,7 +120,7 @@ def get_google_credentials(
97
120
  raise ValueError("sender_email is required to impersonate via service account.")
98
121
 
99
122
  service_account_json = get_google_workspace_token(tool_config)
100
- service_account_info = json.loads(service_account_json)
123
+ service_account_info = _normalize_service_account_info(service_account_json)
101
124
 
102
125
  # Create Credentials object and impersonate the sender_email
103
126
  credentials = service_account.Credentials.from_service_account_info(
@@ -709,8 +709,8 @@ def extract_company_page(url: str) -> str:
709
709
  @assistant_tool
710
710
  async def find_organization_linkedin_url_with_google_search(
711
711
  company_name: str,
712
- company_location: Optional[str] = None,
713
- company_domain: Optional[str] = None,
712
+ company_location: str = "",
713
+ company_domain: str = "",
714
714
  use_strict_check: bool = True,
715
715
  tool_config: Optional[List[Dict]] = None,
716
716
  ) -> str:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dhisana
3
- Version: 0.0.1.dev255
3
+ Version: 0.0.1.dev257
4
4
  Summary: A Python SDK for Dhisana AI Platform
5
5
  Home-page: https://github.com/dhisana-ai/dhisana-python-sdk
6
6
  Author: Admin
@@ -40,7 +40,7 @@ dhisana/utils/g2_tools.py,sha256=a4vmBYCBvLae5CdpOhMN1oNlvO8v9J1B5Sd8T5PzuU8,334
40
40
  dhisana/utils/generate_content.py,sha256=kkf-aPuA32BNgwk_j5N6unYHOZpO7zIfO6zP95XM9fA,2298
41
41
  dhisana/utils/generate_custom_message.py,sha256=_m_8akk5eHyD6nNvzbhnFVmOp_v14rB-jDTVKk1PHOQ,11988
42
42
  dhisana/utils/generate_email.py,sha256=YUhrku9meo3ee5Ft2ybtLTUTAfUf4quPmJp9hmSkdzM,12895
43
- dhisana/utils/generate_email_response.py,sha256=3pggNoJKwZ0bAZ3aKaelw7Qip7AsySh16Qw_36Q0Mh4,21212
43
+ dhisana/utils/generate_email_response.py,sha256=lFcpgOthpce4tSoB8xhlqD5yVEC_nJrFvyJYoZZ0z6E,19420
44
44
  dhisana/utils/generate_flow.py,sha256=QMn6bWo0nH0fBvy2Ebub1XfH5udnVAqsPsbIqCtQPXU,4728
45
45
  dhisana/utils/generate_leads_salesnav.py,sha256=AONP1KXDJdg95JQBmKx5PQXUD2BHctc-MZOMuRfuK9U,12156
46
46
  dhisana/utils/generate_linkedin_connect_message.py,sha256=WZThEun-DMuAOqlzMI--hGmrDuQUYEb4Hl2DoMv3s80,9885
@@ -48,7 +48,7 @@ dhisana/utils/generate_linkedin_response_message.py,sha256=-jg-u5Ipf4-cn9q0yjEHs
48
48
  dhisana/utils/generate_structured_output_internal.py,sha256=DmZ5QzW-79Jo3JL5nDCZQ-Fjl8Nz7FHK6S0rZxXbKyg,20705
49
49
  dhisana/utils/google_custom_search.py,sha256=5rQ4uAF-hjFpd9ooJkd6CjRvSmhZHhqM0jfHItsbpzk,10071
50
50
  dhisana/utils/google_oauth_tools.py,sha256=ReG5lCpXL3_e_s0yn6ai4U7B4-feOWHJVtbv_c0g0rE,28525
51
- dhisana/utils/google_workspace_tools.py,sha256=zTKMyqRj1kAVCBrUPZXjkxANamKFhbvp1er0ftHD3S4,49175
51
+ dhisana/utils/google_workspace_tools.py,sha256=fuV0UcvAqF9drLzj7-p6D5zh7d5jMXl1jNJTICk4XOo,50224
52
52
  dhisana/utils/hubspot_clearbit.py,sha256=keNX1F_RnDl9AOPxYEOTMdukV_A9g8v9j1fZyT4tuP4,3440
53
53
  dhisana/utils/hubspot_crm_tools.py,sha256=lbXFCeq690_TDLjDG8Gm5E-2f1P5EuDqNf5j8PYpMm8,99298
54
54
  dhisana/utils/instantly_tools.py,sha256=hhqjDPyLE6o0dzzuvryszbK3ipnoGU2eBm6NlsUGJjY,4771
@@ -76,7 +76,7 @@ dhisana/utils/serpapi_additional_tools.py,sha256=Xb1tc_oK-IjI9ZrEruYhFg8UJMLHQDa
76
76
  dhisana/utils/serpapi_google_jobs.py,sha256=HUJFZEW8UvYqsW0sWlEDXgI_IUomh5fTkzRJzEgsDGc,4509
77
77
  dhisana/utils/serpapi_google_search.py,sha256=B3sVq2OXdrYmPbH7cjQN4RFoek96qgKzXIayKXn0HLU,7318
78
78
  dhisana/utils/serpapi_local_business_search.py,sha256=vinmuXLaQ_0BpEdwnONZ2vLTq5xnRh6ICmPbnpckSN4,5775
79
- dhisana/utils/serpapi_search_tools.py,sha256=xiiYi6Rd6Mqn94mjSKEs5nNZk1l2-PW_hTL4grvxUpI,31722
79
+ dhisana/utils/serpapi_search_tools.py,sha256=Wsvy6JDYWBGhIomWcjZiYcWe7ALTO7CORsNG8whyyQg,31698
80
80
  dhisana/utils/serperdev_google_jobs.py,sha256=m5_2f_5y79FOFZz1A_go6m0hIUfbbAoZ0YTjUMO2BSI,4508
81
81
  dhisana/utils/serperdev_local_business.py,sha256=JoZfTg58Hojv61cyuwA2lcnPdLT1lawnWaBNrUYWnuQ,6447
82
82
  dhisana/utils/serperdev_search.py,sha256=_iBKIfHMq4gFv5StYz58eArriygoi1zW6VnLlux8vto,9363
@@ -95,8 +95,8 @@ dhisana/workflow/agent.py,sha256=esv7_i_XuMkV2j1nz_UlsHov_m6X5WZZiZm_tG4OBHU,565
95
95
  dhisana/workflow/flow.py,sha256=xWE3qQbM7j2B3FH8XnY3zOL_QXX4LbTW4ArndnEYJE0,1638
96
96
  dhisana/workflow/task.py,sha256=HlWz9mtrwLYByoSnePOemBUBrMEcj7KbgNjEE1oF5wo,1830
97
97
  dhisana/workflow/test.py,sha256=E7lRnXK0PguTNzyasHytLzTJdkqIPxG5_4qk4hMEeKc,3399
98
- dhisana-0.0.1.dev255.dist-info/METADATA,sha256=lwJJzuSsIrzXyK7pli9XTZzeEy8aTJAkYLKAeWDgT9c,1190
99
- dhisana-0.0.1.dev255.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
100
- dhisana-0.0.1.dev255.dist-info/entry_points.txt,sha256=jujxteZmNI9EkEaK-pOCoWuBujU8TCevdkfl9ZcKHek,49
101
- dhisana-0.0.1.dev255.dist-info/top_level.txt,sha256=NETTHt6YifG_P7XtRHbQiXZlgSFk9Qh9aR-ng1XTf4s,8
102
- dhisana-0.0.1.dev255.dist-info/RECORD,,
98
+ dhisana-0.0.1.dev257.dist-info/METADATA,sha256=7R2CrO9xKlOsUiKt0px0PABQv_WjlLPLTOEGDdHcP3Q,1190
99
+ dhisana-0.0.1.dev257.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
100
+ dhisana-0.0.1.dev257.dist-info/entry_points.txt,sha256=jujxteZmNI9EkEaK-pOCoWuBujU8TCevdkfl9ZcKHek,49
101
+ dhisana-0.0.1.dev257.dist-info/top_level.txt,sha256=NETTHt6YifG_P7XtRHbQiXZlgSFk9Qh9aR-ng1XTf4s,8
102
+ dhisana-0.0.1.dev257.dist-info/RECORD,,